function plotFit(setup,output)

numRowFig   = 4;
numColFig   = 3;
dates       = datenum(setup.timeIndex);
fullPlotON  = 0;
%% For nominal bond yields
numYields   = size(output.yHatTrans,2);
if fullPlotON == 1
    % Plotting the fit of nominal yields
    idx         = 0;
    for k=1:ceil(numYields/(numRowFig*numColFig))
        figure('Name',['Fit of yields: ',num2str(k)],'NumberTitle','off');
        for i=1:numRowFig*numColFig
            idx = idx + 1;
            if idx <= numYields
                subplot(numRowFig,numColFig,i)
                hold on
                timeIndex = str2num(datestr(dates,10))+str2num(datestr(dates,5))/12;
                plot(timeIndex,output.yHatTrans(:,idx),'-r')
                plot(timeIndex,setup.yields(:,idx),'-k')
                title(['Maturity = ',num2str(setup.matSelect(1,idx)/12), ' year']);
                axis tight
            end
            if i == 1
                legend('model','data')
            end
        end
    end
    % Plotting the residuals of nominal yields
    idx         = 0;
    for k=1:ceil(numYields/(numRowFig*numColFig))
        figure('Name',['Fit of yields: ',num2str(k)],'NumberTitle','off');
        for i=1:numRowFig*numColFig
            idx = idx + 1;
            if idx <= numYields
                subplot(numRowFig,numColFig,i)
                hold on
                timeIndex = str2num(datestr(dates,10))+str2num(datestr(dates,5))/12;
                plot(timeIndex,(output.residuals(idx,:))*10000,'-r')
                title(['Maturity = ',num2str(setup.matSelect(1,idx)/12), ' year']);
                axis tight
                ylabel('Basis points')
            end
        end
    end
end
figure('Name','Nominal Bond Yields: Moments','NumberTitle','off');
meanResPerYield = zeros(1,numYields);
stdResPerYield  = zeros(1,numYields);
for i=1:numYields
    select  = ~isnan(output.residuals(i,:));
    res     = output.residuals(i,select)'*10000;
    meanResPerYield(1,i) = mean(res,1);
    stdResPerYield(1,i)  = std(res,1);
end
subplot(2,1,1)
bar(setup.matSelect/12,meanResPerYield)
axis tight
ylabel('Basis points')
ylabel('Maturity in years')
title('Nominal Bond Yields: Mean of residuals by maturity')
subplot(2,1,2)
bar(setup.matSelect/12,stdResPerYield)
axis tight
ylabel('Basis points')
ylabel('Maturity in years')
title('Nominal Bond Yields: Std of residuals by maturity')


end